<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>兑奖记录管理</title>
<script type="text/javascript">
$.datepicker();
	$(function() {
		$.jgrid.ajaxOptions.type = 'post';
		$("#gridTable")
				.jqGrid(
						{
							url : 'cms/record/view',
							datatype : "json",
							autowidth : true,
							rownumbers : true,
							height : 370,
							colNames : [  '兑换日期', '兑换时间', '兑换人姓名', '兑换人电话','奖品名称','联系地址','操作' ],
							colModel : [
							 {
								name : 'changeDateStr',
								index : 'changeDateStr',
								width : 90
							}, {
								name : 'changeTimeStr',
								index : 'changeTimeStr',
								width : 90
							},  {
								name : 'customerName',
								index : 'customerName',
								width : 50
							}, {
								name : 'mobile',
								index : 'mobile',
								width : 60
							}, {
								name : 'prizeName',
								index : 'prizeName',
								width : 80
							},{
								name : 'address',
								index : 'address',
								width : 100
							}, {
								label : '操作',
								name : 'operation',
								index : 'operation',
								width: 50,
								formatter:function(cell,options,row){
									var	result = '<a href="#" onclick="detailDialog(\''+row.id+'\')">详情</a>';
									return result;
								}
							} ],
							viewrecords : true,
							rowNum : 20,
							rowList : [ 20, 40 ],
							jsonReader : {
								root : "data",
								page : "index",
								total : "total",
								records : "totalRecord",
								repeatitems : false
							},
							pager : "#pgtoolbar1"
						});
	});
	
	function detailDialog(id){
		showDialog('cms/record/detail/page?id='+id+'&rand='+Math.random(),{width:'900px',title:'兑换记录详情',lock:true});
	}
	
	var myDialog;
	function showDialog(url,options){
		myDialog = art.dialog(options);// 初始化一个带有loading图标的空对话框
		jQuery.ajax({
			url: url,
			success: function (data) {
			myDialog.content(data);// 填充对话框内容
			}
		});
	}

	function search() {
		var param = {
				customerName : $('#customerName').val(),
				mobile : $('#mobile').val(),
				beginDate : $('#beginDate').val(),
				endDate : $('#endDate').val()
		};
		 
		var postData = $("#gridTable").jqGrid("getGridParam", "postData");
		$.extend(postData, param);
		$("#gridTable").jqGrid("setGridParam").trigger("reloadGrid", [ {
			page : 1
		} ]);
	}
</script>
</head>
<body>
	<div class="r_location">
		<i class="r_txtico"></i> 内容管理 &gt; 兑换记录管理
	</div> 

	<form id="rForm" action="" method="POST">
		<ul class="all_list">
			<li>
				<span class="all_title">客户姓名：</span> 
				<span><input type="text" id="customerName" name="customerName" class="ui_input" /></span>
				<span class="all_title">客户手机号码:</span> 
				<span><input type="text" id="mobile" name="mobile" class="ui_input" /></span>
			</li>
			<li>
				<span class="all_title">兑换时间：</span> 
				<span>
					<input type="text" id="beginDate1" name="beginDate" class="ui_input datepicker Wdate" dateFormat="yyyy-MM-dd HH:mm:ss" group='{"group": {"startId":"beginDate1", "endId":"endDate1","showNext": true}}' option='start-auto-end' />至 
					<input type="text" id="endDate1" name="endDate" dateFormat="yyyy-MM-dd HH:mm:ss" class="ui_input datepicker Wdate" validator='{"label":"有效时间","required":true}' option='start-auto-end'/>
				</span>
			</li>
			<li>
				<span class="all_title"></span> 
				<span><input type="button"
					onclick="search()" value="查询" class="search_btn m-r15" /> <input
					type="reset" value="重置" class="reset_btn" /> <input type="button"
					onclick="exportRole()" value="导出" class="search_btn m-r15" /></span>
			</li>
		</ul>
		<div class="clearfix table_fn">
			<span class="l">兑换记录管理数据列表</span>
		</div>
		<table id="gridTable">
		</table>
		<div id="pgtoolbar1"></div>
	</form>
	 
	<script type="text/javascript">
		var myDialog;

		function addDialog() {
			showDialog('role/add/page', {
				width : '600px',
				title : '角色添加',
				lock : true
			});
		}

		function modifyDialog(id) {
			showDialog('cms/role/modify/page?id=' + id + '&rand=' + Math.random(),
					{
						width : '600px',
						title : '角色修改',
						lock : true
					});
		}

		function permisDialog(id) {
			showDialog('cms/role/auths/page/' + id + '?rand=' + Math.random(), {
				width : '650px',
				title : '角色授权',
				lock : true
			});
		}

		function exportRole() {
			$('#rForm').attr("action", "cms/record/changeRecord/getChangeRecordExcel");
			$('#rForm').submit();
		}

		function configDefault(id, flag) {
			myDialog = art.dialog({
				lock : true,
				content : flag == 0 ? '确定设置为默认角色？' : '确定取消默认角色？',
				ok : function() {
					$.ajax({
						url : 'role/config?roleId=' + id + '&flag=' + flag,
						tokenId: 'role_default',
						success : function(data) {
							art.dialog({
								icon : data.success,
								content : data.message,
								lock : true
							}).time(3);
							$("#gridTable").trigger("reloadGrid", [ {
								page : 1
							} ]);
						}
					});
				},
				cancelVal : '关闭',
				cancel : true
			//为true等价于function(){}
			});

		}

		function delDialog(id) {
			jQuery.ajax({
				url : 'role/del/check?roleId=' + id,
				success : function(data) {
					if (data.success == 'succeed') {
						myDialog = art.dialog({
							lock : true,
							content : '是否确定删除此角色?',
							ok : function() {
								jQuery.ajax({
									url : "role/del/" + id,
									tokenId: 'role_delete',
									success : function(data) {
										myDialog = art.dialog({
											icon : data.success,
											content : data.message,
											lock : true
										});
										$("#gridTable").trigger("reloadGrid",
												[ {
													page : 1
												} ]);
									}
								});
							},
							cancelVal : '关闭',
							cancel : true
						//为true等价于function(){}
						});
					} else {
						myDialog = art.dialog({
							icon : data.success,
							content : data.message,
							lock : true
						});
					}
				}
			});

		}

		function showDialog(url, options) {
			myDialog = art.dialog(options);// 初始化一个带有loading图标的空对话框
			jQuery.ajax({
				url : url,
				success : function(data) {
					myDialog.content(data);// 填充对话框内容
				}
			});
		}
	</script>
</body>
</html>